package com.my.hp_hr.dao.liuhao_dao;

import com.my.hp_hr.entity.liuhao_entity.Department;
import com.my.hp_hr.entity.liuhao_entity.Employee;
import com.my.hp_hr.entity.liuhao_entity.Position;
import com.my.hp_hr.util.BaseDAO;

public class EmployeeDao extends BaseDAO {
    public Employee checkEmployeeByNumAndPassword(String number, String password) throws Exception {
        String sql="select * from employee where employee_number=? and password=?;";
        Object[]objects={number,password};
        return  getOne(sql,new Employee(),objects);
    }

    public Employee selectemployeedetail(int id) throws Exception {
        String sql="select * from employee where id=?;";
        Object[]objects={id};
        return getOne(sql,new Employee(),objects);
    }

    public Position selectpositiondetailByPosition_number(int position_number) throws Exception {
       String sql="select * from position where position_number=?;";
       Object[]objects={position_number};
       return getOne(sql,new Position(),objects);
    }

    public Department selectdepartmentdetailByPosition_number(int department_number) throws Exception {
        String sql="select * from department where department_number=?;";
        Object[]objects={department_number};
        return getOne(sql,new Department(),objects);
    }

    public void updateEmployeeInfo(Employee employee) throws Exception {
        String sql="update employee set name=?,password=?,gender=?,birthday=?,telephone=?,email=?,address=?,education=?,notes=? where id=?;";

        Object[]objects={employee.getName(),employee.getPassword(),employee.getGender(),employee.getBirthday()
        ,employee.getTelephone(),employee.getEmail(),employee.getAddress(),employee.getEducation(),employee.getNotes(),employee.getId()};
       addOrupdOrdel(sql,objects);
    }
}
